﻿using System;
using System.Collections.Generic;
using System.Text;
using net.veekee.common.reflection;
using net.veekee.logprocessor.plugin.output;
using net.veekee.common;
using net.veekee.logprocessor.plugin.input;

namespace net.veekee.logprocessor.plugin.wireshark
{
    public class InputHandler : ITypeListHandler
    {
        public void OnRegister()
        {
            InputFactory.Register("wireshark", typeof(PCAPProcessor).FullName);
            Options.GetInstance().Add(new Option() { Name = "input.wireshark.pattern", MandatoryValidation = new MandatoryOptionValidatorHandler(InputHandler.MandatoryOptionValidatorMakesItDepends), NoArgument = false, Description = "Set the Wireshark filter expression", DefaultValue = "" });
        }

        private static bool MandatoryOptionValidatorMakesItDepends(object sender, params Object[] args)
        {
            switch (sender.ToString())
            {
                case "input.wireshark.filter":
                    return (Options.GetInstance().Get("input.format") == "wireshark");
            }
            return false;
        }

    }
}
